import { DeviceConfiguration } from '@/type/typings';

/**
 * 根据手机型号返回相应图标
 * @param model 手机型号
 */
export function getDeviceIconByModel(model: string) {
  if (model) {
    if (/^MI_/.test(model)) {
      return 'icon-xiaomi';
    }
  }

  return 'icon-android';
}

export function getDefaultConfig(): DeviceConfiguration {
  return {
    title: '',
    record: {
      open: false,
      openMirror: true,
      filepath: 'C:/record.mkv'
    },
    screen: false,
    fixed: false,
    control: true,
    touch: false,
    render: false,
    bitRate: 8,
    maxSize: 0,
    crop: {
      x: 0,
      y: 0,
      height: 0,
      width: 0
    }
  };
}

export function isIpAddr(str: string) {
  return /^(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])$/.test(
    str
  );
}
